import service from '@/utils/http'

// 获取产品列表
export const getProductList = (params: {
  page?: number
  pageSize?: number
  keyword?: string
}) => {
  return service.get('/api/products', { params })
}

// 获取产品详情
export const getProductDetail = (id: string | number) => {
  return service.get(`/api/products/${id}`)
}

// 创建产品
export const createProduct = (data: {
  name: string
  price: number
  description?: string
}) => {
  return service.post('/api/products', data)
}

// 更新产品
export const updateProduct = (
  id: string | number,
  data: { name?: string; price?: number; description?: string }
) => {
  return service.put(`/api/products/${id}`, data)
}

// 删除产品
export const deleteProduct = (id: string | number) => {
  return service.delete(`/api/products/${id}`)
}
